<template>
	<view class="preview">
		<!-- 轮播图片区域 start -->
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular>
			<swiper-item v-for="item in 6">
				<image @click="maskChange" src="../../common/images/preview1.jpg" mode="aspectFill"></image>
			</swiper-item>

		</swiper>
		<!-- 轮播图片区域 end -->

		<!-- 遮罩层 start -->
		<view class="mask" v-if="maskStatus">
			<view class="go-back" @click="goBack" :style="{top:getStatusBarHeight() + 'px'}">
				<uni-icons type="back" color="#fff" size="20"></uni-icons>
			</view>
			<view class="count">
				3 / 9
			</view>
			<view class="time">
				<uni-dateformat :date="new Date()" format="hh:mm
				"></uni-dateformat>
			</view>
			<view class="date">
				<uni-dateformat :date="new Date()" format="MM月dd日
				"></uni-dateformat>
			</view>

			<view class="footer">
				<view class="box" @click="clickInfoPopup">
					<uni-icons type="info" size="28"></uni-icons>
					<view class="text">
						信息
					</view>
				</view>
				<view class="box" @click="clickStar">
					<uni-icons type="star" size="28"></uni-icons>
					<view class="text">
						5分
					</view>
				</view>
				<view class="box">
					<uni-icons type="download" size="28"></uni-icons>
					<view class="text">
						下载
					</view>
				</view>

			</view>
		</view>
		<!-- 遮罩层 end -->

		<!-- 底部弹出层 start -->
		<uni-popup ref="infoPopupRef" type="bottom">
			<view class="infoPopup">
				<view class="popHeader">
					<view>

					</view>
					<view class="title">
						壁纸信息
					</view>
					<view class="close" @click="onClose">
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>

				<scroll-view scroll-y="true">
					<view class="content">
						<view class="row">
							<view class="label">
								壁纸id
							</view>
							<text selectable class="label-content">
								xxxxxxxxxx
							</text>

						</view>
						<view class="row">
							<view class="label">
								分类
							</view>
							<text selectable class="label-content class">
								美女
							</text>

						</view>
						<view class="row">
							<view class="label">
								发布者
							</view>
							<text selectable class="label-content">
								TJN
							</text>

						</view>

						<view class="row">
							<view class="label">
								评分
							</view>
							<view selectable class="label-content rote-box">
								<uni-rate :touchable="false" readonly :value="starValue" />
								<text class="score"> 5分</text>
							</view>

						</view>

						<view class="row">
							<view class="label">
								摘要
							</view>
							<text selectable class="label-content">
								摘要内容摘要内容摘要内容摘要内容摘要内容摘要内容摘要内容摘要内容摘要内容摘要内容摘要内容
							</text>

						</view>

						<view class="row">
							<view class="label">
								标签
							</view>
							<view selectable class="label-content tabs">
								<view class="text" v-for="(item,index) in 3">
									标签
								</view>

							</view>


						</view>
						
						<view class="copy-right">
							声明信息阿斯蒂芬萨芬士大夫士大夫倒萨阿斯顿阿斯蒂芬撒地方飒飒大发射点发射点发射点的撒
						</view>

					</view>

				</scroll-view>
			</view>
		</uni-popup>
		<!-- 底部弹出层 end -->
		
		<uni-popup :is-mask-click ="false" ref="scorePopup">
			<view class="score-popup">
				<view class="popHeader">
					<view>
				
					</view>
					<view class="title">
						壁纸评分
					</view>
					<view class="close" @click="onScoreClose">
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>
				
				<view class="content">
					<uni-rate allowHalf   :value="scroeValue" @change="changeScoreCount" />
					<text class="text">{{ scroeValue }}分</text>
				</view>
				
				<view class="footer" >
					<button @click="submitScore" :disabled="!scroeValue" type="default" size="mini" plain>确认评分</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
	import {
		ref
	
	} from 'vue';
import { getStatusBarHeight } from '@/utils/system.js'

// 点击评分
const scroeValue = ref(0)
// 评分ref
const scorePopup = ref(null)
// 打开评分弹窗
function clickStar(){
	scorePopup.value.open()
}
// 关闭评分弹窗
function onScoreClose(){
	scorePopup.value.close()
}
// 改变评分分数
function changeScoreCount(e){
	console.log(e.value,'评分数量');
	scroeValue.value = e.value 
}
// 提交评分
function submitScore(){
	
}


	// 遮罩层状态
	const maskStatus = ref(true)

	// 弹出层Ref
	const infoPopupRef = ref(null)
	// 返回
	function goBack() {
		uni.navigateBack()
	}
	
	

	// 点击图片显示或者关闭遮罩层
	function maskChange() {
		maskStatus.value = !maskStatus.value
	}

	// 开始关闭信息弹层
	function clickInfoPopup() {
		console.log('infoPopup');
		infoPopupRef.value.open()
	}
	
	function onClose(){
		infoPopupRef.value.close()
	}
</script>

<style lang="scss" scoped>
	.preview {
		position: relative;
		width: 100%;
		height: 100vh;

		swiper {
			width: 100%;
			height: 100%;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.mask {

			&>view {
				position: absolute;
				left: 0;
				right: 0;
				width: fit-content;
				color: #fff;
				margin: auto;
			}

			.go-back {
				display: flex;
				justify-content: center;
				align-items: center;
				height: 38px;
				width: 38px;
				background-color: rgba(0, 0, 0, 0.5);
				left: 30rpx;
				margin-left: 0;
				border-radius: 100px;
				top: 0;
				backdrop-filter: blur(10rpx);
				border: 1rpx solid rgba(255, 255, 255, 0.3);
			}

			.count {
				top: 10vh;
				margin: auto;
				background: rgba(0, 0, 0, 0.3);
				backdrop-filter: blur(10rpx);
				font-size: 28rpx;
				border-radius: 40rpx;
				padding: 8rpx 28rpx;

			}

			.time {
				font-size: 140rpx;
				top: calc(10vh + 80rpx);
				font-weight: 100;
				line-height: 1em;
				text-shadow: 0 4rpx rgba(0, 0, 0, 0.3);
			}

			.date {
				font-size: 34rpx;
				top: calc(10vh + 230rpx);
				text-shadow: 0 2rpx rgba(0, 0, 0, 0.3);
			}

			.footer {
				display: flex;
				justify-content: space-around;
				align-items: center;
				bottom: 10vh;
				width: 65vw;
				height: 120rpx;
				border-radius: 120rpx;
				color: #000;
				background: rgba(255, 255, 255, 0.8);
				box-shadow: 0 2rpx 0 rgba(0, 0, 0, 0.1);
				backdrop-filter: blur(20rpx);

				.box {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					padding: 2rpx 12rpx;

					.text {
						font-size: 26rpx;
						color: #777;
					}
				}
			}
		}
		
		
		.popHeader {
			display: flex;
			justify-content: space-between;
			align-items: center;
		
			.title {
				color: #676767;
				font-size: 26rpx;
			}
		
			.close {
				padding: 6rpx;
			}
		}
		

		.infoPopup {
			background: #fff;
			padding: 30rpx;
			border-radius: 30rpx 30rpx 0 0;
			overflow: hidden;

			.popHeader {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.title {
					color: #676767;
					font-size: 26rpx;
				}

				.close {
					padding: 6rpx;
				}
			}

			scroll-view {
				height: 40vh;

				.content {

					.row {
						display: flex;
						padding: 16rpx 0;
						font-size: 32rpx;
						line-height: 1.7em;

						.label {
							text-align: right;
							color: #a7a7a7;
							width: 140rpx;
							font-size: 30rpx;
							margin-right: 20rpx;
						}

						.label-content {
							flex: 1;
							width: 0;
						}

						.rote-box {
							display: flex;
							align-items: center;

							.score {
								font-size: 26rpx;
								color: #a7a7a7;
								padding-left: 20rpx;
							}
						}

						.class {
							color: #a7a7a7;
						}
						


						.tabs {
							display: flex;
							flex-wrap: wrap;
							align-items: center;
							color: #a7a7a7;

							.text {
								border: 1px solid #a7a7a7;
								font-size: 22rpx;
								padding: 10rpx 30rpx;
								border-radius: 40rpx;
								line-height: 1em;
								marign: 0 10rpx;
							}
						}
					}
				}
			}
		}
		
		
		.score-popup{
			background: #fff;
			padding: 30rpx;
			width: 70vw;
			border-radius: 30rpx;
			
			.content{
				display: flex;
				align-items: center;
				justify-content: center;
				padding:30rpx 0;
				
				.text{
					color: #ffca3e;
					padding-left: 10rpx;
					width: 80rpx;
					line-height: 1em;
					text-align: right;
				}
			}
			
			.footer{
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
		
		.copy-right{
			font-size:28rpx;
			padding: 20rpx;
			background: #f6f6f6;
			color: #666;
			border-radius: 10rpx;
			margin: 20rpx 0;
			line-height: 1.6em;
		}
	}
</style>